<?php
	header("Content-Type: text/html;charset=utf-8");
	include("function/_nosql.php"); //
	include("function/function.php");
	include("_include.user.judge.php");
	$kboy_userid = $_SESSION['kboy_userid'];
	$kboy_user = $_SESSION['kboy_user'];
	$action = chkstr(trim($_REQUEST['action']));
	$score_text = chkstr(trim($_REQUEST['ratyValue']));
	$score_impression = chkstr(trim($_REQUEST['spanValue']));
	$orderid = chkstr(trim($_REQUEST['orderid']));
	if($action == "addping"){
		if(!is_numeric($orderid)){
		  echo erro("参数错误！");
		}
		if(getNewsNums("kboy_order","uid=$kboy_userid and id=$orderid") <1){
		  echo erro("参数错误");
		}
		$newsid = getClassName("kboy_order","aid","uid=$kboy_userid and id=$orderid");
		$mysql = new sqlstr("kboy_active_score"); 
		if(getNewsNums("kboy_active_score","uid=$kboy_userid and orderid=$orderid") <1){//新增		   
		   $mysql -> set("uid",$kboy_userid);
		   $mysql -> set("newsid",$newsid);
		   $mysql -> set("orderid",$orderid);
		   $mysql -> set("score_text",$score_text);
		   $mysql -> set("score_impression",$score_impression);
		   $news_sql = $mysql -> insertSql();
		   $news_res = mysql_query($news_sql);
		}
		else{//修改
		   $id = getClassName("kboy_active_score","id","uid=$kboy_userid and id=$orderid");
		   $mysql -> set("score_text",$score_text);
		   $mysql -> set("score_impression",$score_impression);
		   $news_sql = $mysql -> updateSql("uid=$kboy_userid  and orderid=$orderid and newsid=$newsid");
		   $news_res = mysql_query($news_sql);
		}
		  //修改好评率
		  $all_num = getNewsNums("kboy_active_score","newsid=$newsid");
		  $grade = getAllCount("kboy_active_score","score_text","newsid=$newsid");
		  $active_favor = (($grade/10)/$all_num);
		  $sql = " update kboy_forum_active set active_favor = ".$active_favor." where  id=$newsid ";
		  mysql_query($sql);
		if($news_res){
			echo '1';
		}else{
			echo '0';
		}
		
	}
	else{
		echo erro("参数错误");
	}
?>